package com.netsdk.web.config;

import com.netsdk.config.AqieConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import static com.netsdk.common.Constant.UPLOAD;

/**
 * @Author aqie
 * @Date 2022/3/26 10:15
 * @desc
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private AqieConfig aqieConfig;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //Windows下
        registry.addResourceHandler(UPLOAD + "**").addResourceLocations("file:" + aqieConfig.getUpload());
        //Mac或Linux下(没有CDEF盘符)
        // registry.addResourceHandler("/uploads/**").addResourceLocations("file:/Users/uploads/");

    }
}
